package com.boatAnchorAssistant.pojo.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.TableComment;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import com.boatAnchorAssistant.pojo.enums.resource.ResourceTypeEnum;
import com.boatAnchorAssistant.pojo.resource.MetaDto;
import lombok.Data;
import nirvana.core.domains.ann.AccEntity;
import nirvana.core.domains.entity.DomainBaseEntity;
import nirvana.core.domains.enums.EntityType;


import javax.persistence.Table;

/**
 * @author Joseph.Li
 * @author joseph.li@king-v.com
 * Created in 2022-06-16 22:51
 *
 *  资源
 */
@Data
@Table
@AccEntity(value = "资源",type = EntityType.SERVICE_ENTITY)
@TableComment("资源")
@TableName(autoResultMap = true)
public class Resource extends DomainBaseEntity<Resource> {



    /**
     * 页面标识
     */
    @Column(type = MySqlTypeConstant.VARCHAR,
            length = 50,
            comment = "页面标识",
            isNull = false,
            defaultValue = "")
    private String name;


    /**
     * 资源名称
     */
    @Column(type = MySqlTypeConstant.VARCHAR,
            length = 50,
            comment = "名称",
            isNull = false,
            defaultValue = "")
    private String resourceName;


    /**
     * 所属模块
     */
    @Column(type = MySqlTypeConstant.BIGINT,
            length = 20,
            comment = "所属模块",
            isNull = false,
            defaultValue = "0")
    private Long modelId;

    /**
     * 资源路径
     */
    @Column(type = MySqlTypeConstant.VARCHAR,
            comment = "资源路径",
            isNull = false,
            defaultValue = "")
    private String path;

    /**
     * 上级id
     *
     * 顶级的上级为0
     */
    @Column(type = MySqlTypeConstant.BIGINT,
            length = 20,
            comment = "上级id",
            isNull = false,
            defaultValue = "0")
    private Long parentId;

    /**
     * 资源类型
     */
    @Column(type = MySqlTypeConstant.TINYINT,
            length = 4,
            comment = "资源类型",
            isNull = false)
    private ResourceTypeEnum type;

    /**
     * 显示顺序
     */
    @Column(type = MySqlTypeConstant.INT,
            length = 11,
            comment = "显示顺序",
            isNull = false)
    private Integer displayOrder;

    /**
     * 备注
     */
    @Column(type = MySqlTypeConstant.VARCHAR,
            comment = "备注",
            isNull = false,
            defaultValue = "")
    private String remark;

    /**
     * 标记(按钮用)
     */
    @Column(type = MySqlTypeConstant.VARCHAR,
            comment = "备注",
            isNull = false,
            defaultValue = "")
    private String tag;

    /**
     * 组件
     */
    @Column(type = MySqlTypeConstant.VARCHAR,
            comment = "组件",
            isNull = false,
            defaultValue = "")
    private String component;


    /**
     * 重定向地址
     */
    @Column(type = MySqlTypeConstant.VARCHAR,
            comment = "备注",
            isNull = false,
            defaultValue = "")
    private String redirect;

    /**
     * 元信息
     */
    @Column(type = MySqlTypeConstant.JSON,
            comment = "元信息")
    @TableField(value = "meta",typeHandler = JacksonTypeHandler.class)
    private MetaDto meta;

    /**
     * 是否隐藏
     */
    @Column(type = MySqlTypeConstant.BIT,
            comment = "是否隐藏",
            isNull = true)
    private Boolean hidden;


    /**
     * 默认资源，不会在配置页面展示，默认授权给用户
     */
    @Column(type = MySqlTypeConstant.BIT,
            comment = "默认资源，不会在配置页面展示，默认授权给用户",
            isNull = false,
            defaultValue = "0")
    private Boolean defaultResource;

}
